package com.blockmeta.bbs.businesslibrary.net.graphqlnet;

import androidx.annotation.NonNull;

import com.apollographql.apollo.ApolloClient;
import com.blockmeta.bbs.baselibrary.BuildConfig;
import com.blockmeta.bbs.businesslibrary.net.retrofit.BaseOKHttpClient;

/**
 * @author by author
 * @date 2019/8/7
 * 初始化Apollo客户端
 */
public class ApolloClientFactory {

    private static ApolloClient apolloClient;
    private static final String BASE_NEWS_URL =  BuildConfig.API_HOST+"/appphp/graphql/app";
//    private static final String BASE_NEWS_URL = "http://testapi.8btc.com/graphql/app";

    @NonNull
    public static ApolloClient getApolloClient() {
        if (apolloClient == null) {
            synchronized (ApolloClientFactory.class) {
                if (apolloClient == null) {
                    apolloClient = ApolloClient.builder()
                                           .serverUrl(BASE_NEWS_URL)
                                           .okHttpClient(BaseOKHttpClient.getIns().buildClient())
                                           .build();

                }
            }
        }
        return apolloClient;
    }

}
